class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x<0:
            return False
        temp=x
        digits=0
        alldigit=[]
        while temp!=0:
            digits+=1
            alldigit.append(temp%10)
            temp//=10
        return sum([val*(10**(digits-i-1)) for i,val in enumerate(alldigit)])==x


class Solution:
    def isPalindrome(self, x: int) -> bool:
        return str(x)[::-1] == str(x)


class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x < 0 or (x % 10 == 0 and x != 0):
            return False
        revertedNumber = 0
        while x > revertedNumber:
            revertedNumber = revertedNumber * 10 + x % 10
            x //= 10
        return x == revertedNumber or x == revertedNumber // 10



s=Solution()
print(s.isPalindrome(120))